function inheritPrototype(SubType, SuperType) {
  // 重要代码!!!
  SubType.prototype = Object.create(SuperType.prototype);

  // 因为我更改了 SubType的prototype ,所以SubType.prototype.constructor 指向 Person
  // 进行下面的更改操作
  Object.defineProperty(SubType.prototype, "constructor", {
    enumerable: false,
    configurable: true,
    writable: true,
    value: SubType,
  });
}

function Person(name, friends) {
  this.name = name;
  this.friends = friends;
}

Person.prototype.eating = function () {
  console.log(this.name + "eating ~~");
};

function Student(name, friends, sno) {
  // 在重新调用一次
  Person.call(this, name, friends);
  this.sno = sno;
}

// 重要处理函数, 这样就可以通过这个函数处理, 前者继承后者
inheritPrototype(Student, Person);

Student.prototype.studying = function () {
  console.log(this.name + "studying");
};

var stu = new Student("xjh", ["xjh2"], 11);
var stu2 = new Student("xjh1", ["keb"], 11);
stu.friends.push(1);
console.log(stu2);
console.log(stu.friends);
stu.eating();
